/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSky.generator.command;

import java.util.Collection;
import ru.jSky.interfaces.Major;

/**
 *
 * @author Rakev
 */
public class ComposeGenerationCommand<T extends Major> implements GenerationCommand<T> {

    private GenerationCommand<T> generationCommand;
    private Collection<ModificationCommand<T>> modificationCommands;

    public ComposeGenerationCommand(GenerationCommand<T> generationCommand, Collection<ModificationCommand<T>> modificationCommands) {
        this.generationCommand = generationCommand;
        this.modificationCommands = modificationCommands;
    }

    @Override
    public T apply(T baseItem) {
        T generatedItem = generationCommand.apply(baseItem);
        for (ModificationCommand<T> modificationCommand : modificationCommands) {
            modificationCommand.apply(generatedItem);
        }
        return generatedItem;
    }
}
